package com.dongjiantong.user.manager;

import com.dongjiantong.common.utils.MD5Util;
import com.dongjiantong.user.mapper.LoginUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author cao
 * @create 2017-11-27 下午6:07
 **/

@Slf4j
@Component
public class UserManager {

    @Resource
    public LoginUserMapper loginUserMapperManager;



    public int updatePassword(Long userId,String password)
    {
        String salt="xyz";
        String newPassword= MD5Util.encrypt(salt+password);

        Map<String,Object> map  = new HashMap<String,Object>();
        map.put("salt",salt);
        map.put("password",newPassword);
        map.put("userId",userId);

        int result =   loginUserMapperManager.updatePassword(map);

        return  result;
    }
}
